<?php

declare(strict_types=1);

namespace app\validate\admin;

use think\Validate;

class AuthAdminsValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'require|number',
        'old_password' => 'require|max:50',
        'new_password' => 'require|max:50',
        're_password' => 'require|max:50',
        'password' => 'require|max:50',
        'user_name' => 'require|max:150',
        'nick_name' => 'max:150',
        'password' => 'require|max:150',
        'group_name' => 'require|max:150',
        'avatar' => 'require|max:150',
        'email' => 'email',
        'mobile' => 'number',
        'status' => 'require|number',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [];

    /**
     * 定义场景，验证不同场景的数据
     */
    protected $scene = [
        'save'  =>  ['user_name', 'password', 'nick_name', 'real_name', 'avatar', 'email', 'mobile'],
        'update' => ['id', 'nick_name', 'real_name', 'avatar', 'email', 'mobile'],
        'password' => ['id', 'old_password', 'new_password', 're_password'],
        'avatar' => ['id', 'avatar'],
    ];
}
